﻿$(document).ready(function () {
    readyok1();
    //if ($("#bigger").length < 1) {
    //    select_id = 9999;
    //    $("#qid").after('<input id="bigger" type="hidden" value="' + select_id + '"/>')
    //}
});

//点击事件
var dblclick = "click";
//当前对象
var k_obj;
var p_obj;
var keydown = 0;

function readyok1() {
    var system = {
        win: false,
        mac: false,
        xll: false
    };

    var p = navigator.platform;
    system.win = p.indexOf("Win") == 0;
    system.mac = p.indexOf("Mac") == 0;
    system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
    if (system.win || system.mac || system.xll) {
        dblclick = "click";
        //$(document).on("click", ".xn", function () {
        //    k_obj = $(this);
        //    eval(k_obj.attr("data-h"))
        //});
    } else {
        dblclick = "touchend"
    }
    $(document).on("touchstart", "div,p,img,h1,h2,h3,h4,h5,h6,span,input,textarea,iframe,em,a",
        function () {
        k_obj = $(this);
        if (k_obj.attr("class") != null) {
            if (k_obj.attr("class").indexOf("xn") >= 0) {
                keydown = 1;
                k_obj.css("margin-top", "5px")
            } else {
                keydown = 2
            }
        } else {
            keydown = 2
        }
    });
    $(document).on("touchmove", "div,p,img,h1,h2,h3,h4,h5,h6,span,input,textarea,iframe,em,a",
        function () {
        if (keydown == 1 || keydown == 2) {
            keydown = 0;
            k_obj.css("margin-top", "0px")
        }
    });
    $(document).on(dblclick, "div,p,img,h1,h2,h3,h4,h5,h6,span,input,textarea,iframe,em,a",
        function () {
        if (keydown == 1) {
            keydown = 0;
            k_obj.css("margin-top", "0");
            eval(k_obj.attr("data-h"))
        } else {

            alert(2);
            if (keydown == 2) {
                if ($("#mymodal").css("display") == "none") {
                    
                    p_obj = k_obj;
                    showedit("a")
                }
            } else {
                if (dblclick == "click") {
                    k_obj = $(this);
                    
                    p_obj = k_obj;
                    showedit("a")
                }
            }
        }
    })
}